<?php
//  王晓梦
use think\facade\Route;
use think\facade\Request;

$version = Request::header('version', 'v1');#接口版本
Route::group('', function () use ($version) {
    // 登录
    Route::group('site', function () use ($version) {
        Route::post('login', "backend/{$version}.Site/login");
    });

    // 后台用户管理
    Route::group('backendMember', function () use ($version) {
        Route::get('read', "backend/{$version}.BackendMember/read");
        Route::get('create', "backend/{$version}.BackendMember/create");
        Route::post('save', "backend/{$version}.BackendMember/save");
        Route::post('update', "backend/{$version}.BackendMember/update");
        Route::get('edit', "backend/{$version}.BackendMember/edit");
        Route::delete('delete', "backend/{$version}.BackendMember/delete");
        Route::get(':id', "backend/{$version}.BackendMember/index");
        //  获取后台角色信息
        Route::get('get-role', "backend/{$version}.BackendMember/getrole");
        Route::get('member-info', "backend/{$version}.BackendMember/memberInfo");
        Route::get('login-out', "backend/{$version}.BackendMember/loginOut");
        //  清除缓存
        Route::get('clear-cache', "backend/{$version}.BackendMember/clearcache");
    })->middleware('checkLogin');

    // 会员管理
    Route::group('member', function () use ($version) {
        Route::get('index', "backend/{$version}.Member/index");
        Route::post('create', "backend/{$version}.Member/create");
        Route::put('update', "backend/{$version}.Member/update");
        Route::delete('delete', "backend/{$version}.Member/delete");
    })->middleware('checkLogin');

    //节点管理
    Route::group('permission', function () use ($version) {
        Route::get('index', "backend/{$version}.BackendPermission/index");
        Route::get('create', "backend/{$version}.BackendPermission/create");
        Route::post('save', "backend/{$version}.BackendPermission/save");
        Route::post('update', "backend/{$version}.BackendPermission/update");
        Route::get('edit', "backend/{$version}.BackendPermission/edit");
        Route::delete('delete', "backend/{$version}.BackendPermission/delete");
    })->middleware('checkLogin');

    //角色管理
    Route::group('role', function () use ($version) {
        Route::get('index', "backend/{$version}.BackendRole/index");
        Route::post('save', "backend/{$version}.BackendRole/save");
        Route::post('update', "backend/{$version}.BackendRole/update");
        Route::get('edit', "backend/{$version}.BackendRole/edit");
        Route::delete('delete', "backend/{$version}.BackendRole/delete");
    })->middleware('checkLogin');

    //角色权限
    Route::group('rolePermission', function () use ($version) {
        Route::get('create', "backend/{$version}.BackendRolePermission/create");
        Route::get('index', "backend/{$version}.BackendRolePermission/index");
        Route::post('save', "backend/{$version}.BackendRolePermission/save");
        Route::post('update', "backend/{$version}.BackendRolePermission/update");
        Route::get('edit', "backend/{$version}.BackendRolePermission/edit");
        Route::delete('delete', "backend/{$version}.BackendRolePermission/delete");
    })->middleware('checkLogin');

    //轮播图管理
    Route::group('banner', function () use ($version) {
        Route::get('index', "backend/{$version}.Banner/index");
        Route::post('create', "backend/{$version}.Banner/create");
        Route::get('edit', "backend/{$version}.Banner/edit");
        Route::post('update', "backend/{$version}.Banner/update");
        Route::delete('delete', "backend/{$version}.Banner/delete");
    })->middleware('checkLogin');

    //上传
    Route::group('upload', function () use ($version) {
        //单图上传
        Route::post('upload', "backend/{$version}.Upload/upload");
        //多图上传
        Route::post('uploads', "backend/{$version}.Upload/uploads");
    });

    //网站基础信息
    Route::group('website', function () use ($version) {
        Route::get('index', "backend/{$version}.Website/index");
        Route::post('create', "backend/{$version}.Website/create");
        Route::get('edit', "backend/{$version}.Website/edit");
        Route::post('update', "backend/{$version}.Website/update");
        Route::delete('delete', "backend/{$version}.Website/delete");
    })->middleware('checkLogin');

    //导航管理
    Route::group('nav', function () use ($version) {
        Route::get('index', "backend/{$version}.Nav/index");
        Route::post('create', "backend/{$version}.Nav/create");
        Route::get('cate', "backend/{$version}.Nav/CateIndex");
        Route::get('edit', "backend/{$version}.Nav/edit");
        Route::post('update', "backend/{$version}.Nav/update");
        Route::delete('delete', "backend/{$version}.Nav/delete");
    })->middleware('checkLogin');

    //分类管理
    Route::group('cate', function () use ($version) {
        Route::get('index', "backend/{$version}.cate/index");//列表
        Route::get('create', "backend/{$version}.cate/create");//获取父级
        Route::post('save', "backend/{$version}.cate/save");//添加
        Route::get('edit', "backend/{$version}.cate/edit");//查看编辑时的数据
        Route::post('update', "backend/{$version}.cate/update");//修改
        Route::delete('delete', "backend/{$version}.cate/delete");//删除
    })->middleware('checkLogin');

    //供应大厅管理
    Route::group('supply', function () use ($version) {
        Route::get('index', "backend/{$version}.Supply/index");//列表
        Route::get('create', "backend/{$version}.Supply/create");//获取父级
        Route::post('save', "backend/{$version}.Supply/save");//添加
        Route::get('edit', "backend/{$version}.Supply/edit");//查看编辑时的数据
        Route::post('update', "backend/{$version}.Supply/update");//修改
        Route::delete('delete', "backend/{$version}.Supply/delete");//删除
    })->middleware('checkLogin');

    //店铺管理
    Route::group('shop', function () use ($version) {
        Route::get('index', "backend/{$version}.Shop/index");
        Route::post('create', "backend/{$version}.Shop/create");
        Route::get('edit', "backend/{$version}.Shop/edit");
        Route::post('update', "backend/{$version}.Shop/update");
        Route::delete('delete', "backend/{$version}.Shop/delete");
    })->middleware('checkLogin');

    //广告位管理
    Route::group('adv', function () use ($version) {
        Route::get('index', "backend/{$version}.Adv/index");
        Route::post('create', "backend/{$version}.Adv/create");
        Route::get('edit', "backend/{$version}.Adv/edit");
        Route::post('update', "backend/{$version}.Adv/update");
        Route::delete('delete', "backend/{$version}.Adv/delete");
    })->middleware('checkLogin');

    //采购大厅管理
    Route::group('purchase', function () use ($version) {
        Route::get('index', "backend/{$version}.Purchase/index");//列表
        Route::get('create', "backend/{$version}.Purchase/create");//获取父级
        Route::post('save', "backend/{$version}.Purchase/save");//添加
        Route::get('edit', "backend/{$version}.Purchase/edit");//查看编辑时的数据
        Route::post('update', "backend/{$version}.Purchase/update");//修改
        Route::delete('delete', "backend/{$version}.Purchase/delete");//删除
    })->middleware('checkLogin');

    //行情大厅管理
    Route::group('quotation', function () use ($version) {
        Route::get('index', "backend/{$version}.Quotation/index");//列表
        Route::get('create', "backend/{$version}.Quotation/create");//获取父级
        Route::post('save', "backend/{$version}.Quotation/save");//添加
        Route::get('edit', "backend/{$version}.Quotation/edit");//查看编辑时的数据
        Route::post('update', "backend/{$version}.Quotation/update");//修改
        Route::delete('delete', "backend/{$version}.Quotation/delete");//删除
    })->middleware('checkLogin');

    //行情资讯管理
    Route::group('info', function () use ($version) {
        Route::get('index', "backend/{$version}.Info/index");//列表
        Route::post('save', "backend/{$version}.Info/save");//添加
        Route::get('edit', "backend/{$version}.Info/edit");//查看编辑时的数据
        Route::post('update', "backend/{$version}.Info/update");//修改
        Route::delete('delete', "backend/{$version}.Info/delete");//删除
    })->middleware('checkLogin');

    //公司黄页管理
    Route::group('enterprise', function () use ($version) {
        Route::get('index', "backend/{$version}.Enterprise/index");//列表
        Route::post('save', "backend/{$version}.Enterprise/save");//添加
        Route::get('edit', "backend/{$version}.Enterprise/edit");//查看编辑时的数据
        Route::post('update', "backend/{$version}.Enterprise/update");//修改
        Route::delete('delete', "backend/{$version}.Enterprise/delete");//删除
    })->middleware('checkLogin');

    //公司管理
    Route::group('company', function () use ($version) {
        Route::get('index', "backend/{$version}.Company/index");//列表
        Route::post('save', "backend/{$version}.Company/save");//添加
        Route::get('edit', "backend/{$version}.Company/edit");//查看编辑时的数据
        Route::post('update', "backend/{$version}.Company/update");//修改
        Route::delete('delete', "backend/{$version}.Company/delete");//删除
    })->middleware('checkLogin');

    //司机报名管理
    Route::group('driver', function () use ($version) {
        Route::get('index', "backend/{$version}.Driver/index");//列表
        Route::get('create', "backend/{$version}.Driver/create");//获取父级
        Route::post('save', "backend/{$version}.Driver/save");//添加
        Route::get('edit', "backend/{$version}.Driver/edit");//查看编辑时的数据
        Route::post('update', "backend/{$version}.Driver/update");//修改
        Route::delete('delete', "backend/{$version}.Driver/delete");//删除
    })->middleware('checkLogin');

    //供应合作管理
    Route::group('cooperation', function () use ($version) {
        Route::get('index', "backend/{$version}.Cooperation/index");//列表
        Route::get('create', "backend/{$version}.Cooperation/create");//获取父级
        Route::post('save', "backend/{$version}.Cooperation/save");//添加
        Route::get('edit', "backend/{$version}.Cooperation/edit");//查看编辑时的数据
        Route::post('update', "backend/{$version}.Cooperation/update");//修改
        Route::delete('delete', "backend/{$version}.Cooperation/delete");//删除
    })->middleware('checkLogin');

    //滞销产品管理
    Route::group('product', function () use ($version) {
        Route::get('index', "backend/{$version}.Product/index");//列表
        Route::post('save', "backend/{$version}.Product/save");//添加
        Route::get('edit', "backend/{$version}.Product/edit");//查看编辑时的数据
        Route::post('update', "backend/{$version}.Product/update");//修改
        Route::delete('delete', "backend/{$version}.Product/delete");//删除
    })->middleware('checkLogin');

})->allowCrossDomain([
    'Access-Control-Allow-Origin' => '*',
    'Access-Control-Allow-Methods' => 'GET,POST,PUT,DELETE',
    'Access-Control-Allow-Headers' => 'content-type,token,version',
    'Access-Control-Allow-Credentials' => 'true'
]);